// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from './request/index'
import wx from './wx/index'
import Mate from './Mate/index'
import './title/index'
import './Logs/index'
import store from './store/index'
import login from './login/index'
import 'animate.css/animate.min.css'
import './assets/icon/iconfont/iconfont.css'
import './assets/css/MasterStyle/index.css'
import MintUI from 'mint-ui'
import 'mint-ui/lib/style.css'
import LazyRender from 'vue-lazy-render'
import * as Sentry from '@sentry/browser'

Vue.use(LazyRender)
Vue.config.productionTip = false
Vue.prototype.$axios = axios
Vue.prototype.$wx = wx
Vue.prototype.$Mate = Mate
Vue.prototype.$Login = login
Vue.use(MintUI)
var prod = "prod";
// import {Toast} from 'mint-ui'
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: {App},
  template: '<App/>',
  beforeCreate: function () {
    this.$Login.jsapi_sign()
    var href = window.location.href;
    if (href.split("?")[1]) {
      var params = href.split("?")[1]
      var paramArr = params.split('&')
      var res = {}
      for (var i = 0; i < paramArr.length; i++) {
        var str = paramArr[i].split('=')
        res[str[0]] = str[1]
      }
      if (res.remove) {
        window.localStorage.removeItem('Ten_Vip_token')
        window.localStorage.removeItem('platform_user_info')
        window.sessionStorage.removeItem('Ten_Vip_share_data')
      }
    }
    // console.log(process)
    if (process.env.NODE_ENV !== 'development') {
      // Raven.Ravens()
      // 初始化sentry
      Sentry.init({
        dsn: 'https://9352f91c539f42ba8802d31cf8acaab5@sentry.qingclass.com/4',
        integrations: [new Sentry.Integrations.Vue({Vue})],
        beforeSend(event) {
          // Check if it is an exception, if so, show the report dialog
          if (event.exception) {
            // 默认弹窗展示
            // Sentry.showReportDialog();
          }
          return event;
        }
      })
      // sentry上下文配置
      if (this.$Login.oauth_token.user_id !== '-1' && this.$Login.oauth_token.user_id !== -1) {
        Sentry.configureScope((scope) => {
          // 设置用户信息
          scope.setUser({
            "id": this.$Login.oauth_token.user_id
          });
          // 设置tag节点  服务器主机名，平台版本，或者用户使用语言
          scope.setTag("version", "1.0.0");
          // 设置警告级别
          scope.setLevel('error');
          // 设置拓展字段
          // scope.setExtra("character_name", "Mighty Fighter");
        });
      }
    }
    // try{
    //   throw new DOMException('我是一个异常')
    // }catch(err){
    //   console.info(err)
    //   Sentry.captureException(err);
    // }
    // var data = {
    //   post_id: -1,
    //   share_type: 20,
    //   share_page: 'Collection'
    // }
    // var obj = {}
    // var _this = this
    // this.$axios.share_link_info(data).then(res => {
    //   var data = {
    //     title: res.data.qing_data.title,
    //     desc: res.data.qing_data.desc,
    //     link: res.data.qing_data.link,
    //     imgUrl: res.data.qing_data.img
    //   }
    //   obj.share_id = res.data.qing_data.share_id
    //   obj.share_token = res.data.qing_data.share_token
    //   _this.$wx.ShareTimeline(data, res => {
    //     obj.share_mode = res.share_mode
    //     obj.share_type = 20
    //     _this.$axios.share_done(obj).then(res => {
    //       if (res.data.qing_code === 100) {
    //         Toast({
    //           message: '分享成功',
    //           iconClass: 'iconfont icon-tianjiachenggong',
    //           duration: 5000
    //         })
    //       } else {
    //         Toast({
    //           message: '分享失败',
    //           iconClass: 'iconfont icon-bangdingshibai',
    //           duration: 5000
    //         })
    //       }
    //     })
    //   })
    //   _this.$wx.ShareAppMessage(data, res => {
    //     obj.share_mode = res.share_mode
    //     obj.share_type = 20
    //     _this.$axios.share_done(obj).then(res => {
    //       if (res.data.qing_code === 100) {
    //         Toast({
    //           message: '分享成功',
    //           iconClass: 'iconfont icon-tianjiachenggong',
    //           duration: 5000
    //         })
    //       } else {
    //         Toast({
    //           message: '分享失败',
    //           iconClass: 'iconfont icon-bangdingshibai',
    //           duration: 5000
    //         })
    //       }
    //     })
    //   })
    // })
    // this.$Login.wx_auth_inspec()
  }
})
